﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project_KhuyenMaiVang.DAO;
using Project_KhuyenMaiVang.Models;

namespace Project_KhuyenMaiVang.Controllers
{
    public class QuanLyDonDatHangController : Controller
    {
        //
        // GET: /QuanLyDonDatHang/

        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public ActionResult update(int idOrder)
        {
            DonDatHang donDatHang = new DonDatHang();
            donDatHang.MaDonDatHang = idOrder;
            ViewBag.OrderStates = (new TinhTrangDonDatHangDAO()).getAllOrderStates();
            return View(donDatHang);
        }

        [HttpPost]
        public ActionResult update(DonDatHang donDatHang)
        {
            DonDatHangDAO donDatHangDAO = new DonDatHangDAO();
            donDatHangDAO.updateOrderState(donDatHang.MaDonDatHang, Int32.Parse(donDatHang.TinhTrangDonHang));
            return RedirectToAction("QuanLyDonDatHang", "Admin");
        }

        public ActionResult delete(int idOrder)
        {
            DonDatHangDAO donDatHangDAO = new DonDatHangDAO();
            donDatHangDAO.deleteOrder(idOrder);
            return RedirectToAction("QuanLyDonDatHang", "Admin");
        }
    }
}
